//
//  NSObject+PDF.m
//  TestDemo
//
//  Created by fantasy on 16/6/26.
//  Copyright © 2016年 goappbox. All rights reserved.
//

#import "NSObject+PDF.h"
#import <UIKit/UIKit.h>

@implementation NSString (PDF)

+ (NSString *)stringWithData:(NSData *)data encoding:(NSStringEncoding)encoding
{
    return [[self alloc] initWithData:data encoding:encoding];
}

- (NSAttributedString *)italicize
{
    UIFont *font;
    NSDictionary *attr;
    
    font = [UIFont fontWithName:@"Helvetica-Oblique" size:14];
    attr = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
    return [[NSAttributedString alloc] initWithString:self attributes:attr];
}

@end

@implementation NSAttributedString (PDF)

+ (NSAttributedString *)attributedStringWithString:(NSString *)string
{
    NSMutableAttributedString *s;
    
    s = [[NSMutableAttributedString alloc] init];
    [s appendString:string];
    return s;
}

@end

@implementation NSMutableAttributedString (PDF)

- (void)appendString:(NSString *)string
{
    UIFont *font;
    NSDictionary *attr;
    NSAttributedString *s;
    
    font = [UIFont fontWithName:@"Helvetica" size:14];
    attr = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
    s = [[NSAttributedString alloc] initWithString:string attributes:attr];
    [self appendAttributedString:s];
}

@end